<?php
/**
 * Created by CommonBill.class.php.
 * User: wuxiang
 * Date: 2016/11/4
 * Time: 17:10
 */

namespace Common\Libiary;

/**
 *
 * local TP_DEBUG = true
 * test TP_DEBUG = true
 * main TP_DEBUG = false
 * Class CommonBill
 * @package Common\Libiary
 */

class CommonBill
{
    /**
     * 搜索接口
     * http://search.mwee.cn/
     * http://es.9now.net/
     * @return string
     */
    public static function getServiceUrl()
    {
        return TP_DEBUG ? ConfigBill::SEARCH_TEST_URL : ConfigBill::SEARCH_PRO_URL;
    }

    /**
     * H5url
     * http://m.9now.net/
     * http://m.mwee.cn/
     * @return string
     *
     */
    public static function getH5Url()
    {
        return TP_DEBUG ? ConfigBill::H5_TEST_URL_PREV : ConfigBill::H5_PRO_URL_PREV;
    }

    /**
     * 短链接服务url
     * http://s.9now.net/admin/short/url
     * http://s.mwee.cn/admin/short/url
     * @return string
     */
    public static function getShortLinkUrl()
    {
        return TP_DEBUG ? ConfigBill::PACKAGE_TEST_URL : ConfigBill::PACKAGE_PRO_URL;
    }

    //获取用户信息url
    public static function getUserInfo()
    {
        return TP_DEBUG ? ConfigBill::USER_INFO_TEST : ConfigBill::USER_INFO_PRO;
    }

    public static function SendCoupons()
    {
        return TP_DEBUG ? ConfigBill::SEND_COUPONS_TEST : ConfigBill::SEND_COUPONS_PRO;
    }

    /**
     *
     * 获取完整的图片路径
     * /upload/20161104/581c55a3f0efe.jpg
     * @param $path
     * @return string
     *
     */

    public static function getImagePath($path)
    {
        return ConfigBill::UPLOAD_PATH.$path;
    }

    /**
     * 返回json数据
     * @param $errno
     * @param $message
     * @param array $data
     * @return string
     */
    public static function echoAjaxJson($errno, $message, $data = [])
    {
        $result['errno'] = $errno;
        $result['errmsg'] = $message;
        $result['data'] = $data;
        echo json_encode($result);
        exit();
    }
}